<template>
  <el-dialog :title="`${form.standardId ? '修改' : '添加'}验收标准`" :visible.sync="show" :close-on-click-modal="false" :show-close="!btnLoading" width="600px" @closed="$refs.form.resetFields()">
    <el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px">
      <el-form-item prop="standardId" class="hide" />
      <el-form-item prop="checktableName" class="hide" />
      <el-form-item label="工序" prop="checktableId" :class="{ hide: !form.checktableName }">{{ form.checktableName }}</el-form-item>
      <el-form-item label="验收标准内容" prop="content"><el-input v-model="form.content" type="textarea" placeholder="请输入验收标准内容" :maxlength="3000" /></el-form-item>
      <el-row>
        <el-col :span="12">
          <el-form-item label="严重等级" prop="seriousLevel">
            <el-select v-model="form.seriousLevel" placeholder="请选择严重等级" default-first-option filterable style="width: 100%">
              <el-option v-for="dict in dict.type.sys_standard_type" :key="dict.value" :label="dict.label" :value="dict.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="模块" prop="modules">
            <el-select v-model="form.modules" placeholder="请选择模块" default-first-option filterable style="width: 100%">
              <el-option v-for="dict in dict.type.cq_data_modules" :key="dict.value" :label="dict.label" :value="dict.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="分块" prop="blocks">
            <el-select v-model="form.blocks" placeholder="请选择分块" default-first-option filterable style="width: 100%">
              <el-option v-for="dict in dict.type.cq_data_blocks" :key="dict.value" :label="dict.label" :value="dict.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="部位" prop="positions">
            <el-select v-model="form.positions" placeholder="请选择部位" default-first-option filterable style="width: 100%">
              <el-option v-for="dict in dict.type.cq_data_positions" :key="dict.value" :label="dict.label" :value="dict.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="数据归集" prop="dataCollections">
            <el-select v-model="form.dataCollections" placeholder="请选择数据归集" default-first-option filterable style="width: 100%">
              <el-option v-for="dict in dict.type.cq_data_collections" :key="dict.value" :label="dict.label" :value="dict.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="排序" prop="seq"><el-input-number v-model="form.seq" :min="0" :max="1e8" :precision="0" controls-position="right" style="width: 100%" /></el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="备注" prop="remark"><el-input v-model="form.remark" type="textarea" placeholder="请输入内容" :maxlength="255" /></el-form-item>
    </el-form>
    <div slot="footer">
      <el-button type="primary" :loading="btnLoading" @click="btnSubmit">确 定</el-button>
      <el-button :disabled="btnLoading" @click="show = false">取 消</el-button>
    </div>
  </el-dialog>
</template>
<script>
// 添加或修改楼栋工序配置的验收标准
import { editFormMixin } from '@/utils/mixin'
// TODO 未验证接口
import { addCheckConfigStandard, updateCheckConfigStandard } from '@/api/qualityManage/cq'
export default {
  name: 'EditCheckConfigStandard',
  mixins: [editFormMixin],
  dicts: ['sys_standard_type', 'cq_data_modules', 'cq_data_blocks', 'cq_data_positions', 'cq_data_collections'],
  data() {
    return {
      primaryKey: 'standardId',
      addApi: addCheckConfigStandard,
      updateApi: updateCheckConfigStandard,
      form: {
        standardId: '',
        checktableId: '',
        checktableName: '',
        content: '',
        seriousLevel: '',
        modules: '',
        blocks: '',
        positions: '',
        dataCollections: '',
        remark: '',
        seq: 0
      },
      rules: {
        content: [{ required: true, message: '请输入验收标准内容' }],
        seriousLevel: [{ required: true, message: '请选择严重等级' }],
        modules: [{ required: true, message: '请选择模块' }]
        // blocks: [{ required: true, message: '请选择分块' }],
        // positions: [{ required: true, message: '请选择部位' }],
        // dataCollections: [{ required: true, message: '请选择数据归集' }]
      }
    }
  }
}
</script>
